/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb;

import java.util.List;
import javax.annotation.Resource;
import javax.ejb.Stateless;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.transaction.UserTransaction;
import manager.OVehiculo;
import manager.VehiculoJpaController;

/**
 *
 * @author Administrador
 */
@Stateless
public class ManagerVehiculo implements ManagerVehiculoLocal {

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    
    @Resource private UserTransaction utx;  
    /*@PersistenceUnit(unitName="EjbSGRPU")
    EntityManagerFactory emf;*/
    @PersistenceUnit(unitName="EjbSGRPU") private EntityManagerFactory emf;
    
    @Override
    public void crearVehiculo(String matricula, String descripcion) {
        try {
            VehiculoJpaController vehiculoJpaController = new VehiculoJpaController(utx, emf);
            OVehiculo vehiculo = new OVehiculo(matricula, descripcion, true);
            /*vehiculoJpaController.create(vehiculo);*/
            System.out.println(vehiculo.getDescripcion());
        } catch (Exception ex) {
            System.out.println(ex.toString());
        }
    }

    @Override
    public void borrarVehiculo(int id) {
    }

    @Override
    public void modificarVehiculo(int id, String matricula, String descripcion, boolean activo) {
    }

    @Override
    public List<OVehiculo> buscarVehiculo(int id, String matricula, String descripcion, boolean activo) {
        return null;
    }
    
    
    
    
}
